package com.ica.model.facade;

import java.util.List;
import java.util.Vector;

import com.ica.model.policy.Policy;

/**
 * @author   Hector
 */
public class PolicyFacadeMockImpl extends GenericFacadeImpl<Policy> implements PolicyFacadeInterface {
	
	/**
	 * @uml.property  name="instance"
	 * @uml.associationEnd  
	 */
	private static PolicyFacadeMockImpl instance;

	private PolicyFacadeMockImpl() {
		
		super();
		/*long idFirst = 0;
		for(int i=1;i<10;i++) {
        	Policy p = new Policy("Policy "+i);
        	if (i==1) idFirst=p.getId();
        	elements.put(p.getId(),p);
        }
		Policy p = elements.remove(idFirst);
		p.setCommand(new RejectCallCommand());
    	ContactGroup contacts = new ContactGroup("Blocked Users");
    	contacts.addContact(new Contact("Pedro","123"));
    	contacts.addContact(new Contact("Maria","1234"));
    	contacts.addContact(new Contact("Samuel","12345"));
    	List<ContactGroup> l = new Vector<ContactGroup>();
    	l.add(contacts);
    	p.setContacts(l);
    	elements.put(p.getId(), p);*/
	}
	
	/**
	 * @return
	 * @uml.property  name="instance"
	 */
	public static PolicyFacadeMockImpl getInstance() {
		
		if (instance==null) {
			instance = new PolicyFacadeMockImpl();
		}
		return instance;
	}
	
	public List<Policy> test(String phoneNumber) {
		
		Vector<Policy> matches = new Vector<Policy>();
		for(Policy policy : elements.values()) {
			if (policy.test(phoneNumber)) matches.add(policy);
		}
		return matches;
	}
}
